package com.example.demo.controller

import com.example.demo.dto.ReceiveData
import com.example.demo.repo.ArtworkCelebrityTitleRepo
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.CrossOrigin
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RestController


@RestController
class TestController {

    @Autowired
    lateinit var artworkCelebrityTitleRepo: ArtworkCelebrityTitleRepo

    // fun a() = 1
    fun a(): Int {
        return 1
    }

    @CrossOrigin("*")
    @PostMapping("/")
    fun test(@RequestBody body: ReceiveData): List<String> {

//        val aaa = animeRepo.save(Artwork())
//        return ReturnData(aaa.aid.toString())
        return artworkCelebrityTitleRepo.findByCidNameContainsAndTidName(body.uploadValue, "导演").map {
            it.aid.name
        }
    }
}

